<?php
/**
 * a Cms_Page is the master container
 *
 */
class Dig_Page
{
    protected $_guid = null;
    /**
     * this is an array of the Cms_Page_Container objects
     *
     * @var array
     */
    protected $_containers = array();
    /**
     * this is an array of the page attributes
     *
     * @var array
     */
    protected $_attributes = array();
    static function load ($guid)
    {
        // this will load the page from the cache, but for now
        return new self($guid);
    }
    /**
     * you can optionally pass a Cms_Page a Zend_Config object
     * if you do it will build the page from the object
     *
     * @param string guid
     * @param Zend_Config $data
     */
    public function __construct ($guid, Zend_Config $data = null)
    {
        $this->_guid = $guid;
        if ($data != null) {
            // create the page             
        }
    }
    public function getGuid ()
    {
        return $this->_guid;
    }
    /**
     * add a new container to the page
     *
     * @param string $key
     * @return Cms_Page_Container
     */
    public function addContainer ($key)
    {
        $container = new Cms_Page_Container();
        $this->_containers[$key] = $container;
        return $container;
    }
    /**
     * test to determine if the page has a container
     *
     * @param string $key
     */
    public function hasContainer ($key)
    {
        return array_key_exists($key, $this->_containers);
    }
    /**
     * get a container from the page
     *
     * @param string $key
     * @return Cms_Page_Container
     */
    public function getContainer ($key)
    {
        if ($this->hasContainer($key)) {
            return $this->_containers[$key];
        }
        return false;
    }
    /**
     * returns all of the pages containers
     *
     * @return array
     */
    public function getContainers ()
    {
        return $this->_containers;
    }
    /**
     * add an attribute to the page
     *
     * @param string $key
     * @param mixed $value
     */
    public function addAttribute ($key, $value)
    {
        $this->_attributes[$key] = $value;
    }
    /**
     * get a specified attribute
     *
     * @param string $key
     * @return mixed
     */
    public function getAttribute ($key)
    {
        if ($this->_attributes[$key]) {
            return $this->_attributes[$key];
        }
        return false;
    }
}
?>